import {Message} from 'element-ui'

export default {
    toast(msg,type="info") {
        Message({
            message: msg,
            type: type,
            showClose: true,
            duration: 2000
        })
    },
    setStorage(key,value) {
        localStorage.setItem(key,value)
    },
    getStorage(key) {
        return localStorage.getItem(key)
    },
    getBirthdayFromIdCard(idCard) {
        let birthday = ''
        if (idCard !== null && idCard !== '') {
            if (idCard.length === 15) {
                birthday = '19' + idCard.substr(6, 6)
            } else if (idCard.length === 18) {
                birthday = idCard.substr(6, 8)
            }
            birthday = birthday.replace(/(.{4})(.{2})/, '$1-$2-')
        }
        return birthday
    }
}